package com.gsta.cdn.cdr.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.gsta.cdn.cdr.entity.ResultEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Mapper
@Component(value = "HotSimilarMapper")
public interface HotSimilarMapper extends BaseMapper<ResultEntity> {
    @Select("<script>" +
            " SELECT * FROM HotSimilar  " +
            " WHERE Date LIKE CONCAT(#{Date},'%')  AND Percent=#{Percent} "+
            "ORDER BY Date " +
            "LIMIT #{page},#{pageSize} "+
            "</script>")
    List<Map<String, Object>> HotSimilar(@Param("Date") String Date, @Param("Percent") String Percent, @Param("page") int page, @Param("pageSize") int pageSize);

    @Select("<script>" +
            "SELECT COUNT(*) AS count FROM ( " +
            " SELECT * FROM HotSimilar  " +
            " WHERE Date LIKE CONCAT(#{Date},'%')  AND Percent=#{Percent})t  "+
            "</script>")
    int HotSimilarCount (@Param("Date") String Date, @Param("Percent") String Percent);
}
